package com.myfarm.service;

//import com.xzff.modulestore.service.CacheService;
import com.alibaba.fastjson.JSON;
import com.myfarm.mapper.TestMapper;
import com.myfarm.vo.Test;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

@Service
@Slf4j
public class TestService {

    @Autowired
    private TestMapper testMapper;

    @Autowired
    DataSource dataSource ;


    public Object test() throws SQLException {

        Test test =  testMapper.selectByPrimaryKey(8);
        log.info(JSON.toJSONString(test));
        return test ;
    }

    public Object test2() throws SQLException {
        Test test =  testMapper.selectByPrimaryKey(8);
        try {
            Thread.sleep(4*1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Connection connection = dataSource.getConnection();
        System.out.println("--->"+connection);
        log.info(JSON.toJSONString(test));
        return test ;
    }

}